package springboot.common_utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author daiqiang
 * &#064;date  2022/1/15-17:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R <T>{
    private  Integer code;
    private String  msg;
    private  T data;

    public R(boolean b, String s) {
    }

    public static  <T> R <T> success(){
        return  new R<>(20000,"success",null);
    }
    public static  <T>R<T> success(T data){
        return  new R<>(20000,"success",data);
    }
    public static  <T>R<T> success(int code,T data){
        return  new R<>(20000,"success",data);
    }
    public static  <T>R<T> success(String msg){
        return  new R<>(20000,msg,null);
    }
    public static  <T>R<T> success( int code,String msg,T data){
        return  new R<>(20000,msg,data);
    }
    public static  <T> R <T> fail(){
        return  new R<>(2001,"success",null);
    }
    public static  <T>R<T> fail(T data){
        return  new R<>(2001,"success",data);
    }
    public static  <T>R<T> fail(T data,String msg){
        return  new R<>(2001,msg,data);
    }
    public static  <T>R<T> fail(String msg){
        return  new R<>(2001,msg,null);
    }
    public static  <T>R<T> fail(int code,String msg){
        return  new R<>(2001,msg,null);
    }



}
